package com.freedom.ums.member.interfaces.controller.admin;

import com.freedom.common.core.result.CommonResult;
import com.freedom.common.core.result.PageResult;
import com.freedom.ums.member.application.service.cmd.MemberCmdService;
import com.freedom.ums.member.application.service.query.MemberQueryService;
import com.freedom.ums.member.infrastructure.persistence.pojo.command.admin.AdminMemberStatusCommand;
import com.freedom.ums.member.infrastructure.persistence.pojo.query.admin.AdminMemberPageQuery;
import com.freedom.ums.member.infrastructure.persistence.pojo.vo.admin.AdminMemberPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "「管理端」会员管理")
@RestController
@RequestMapping("/api/member")
@RequiredArgsConstructor
public class AdminMemberController {

    private final MemberQueryService memberQueryService;

    private final MemberCmdService memberCmdService;

    @ApiOperation(value = "会员分页列表")
    @GetMapping("/page")
    public PageResult<AdminMemberPageVO> queryMemberPage(@Validated AdminMemberPageQuery queryParam) {
        return PageResult.success(memberQueryService.queryMemberPage(queryParam));
    }

    @ApiOperation(value = "会员状态修改")
    @PutMapping("/status")
    public CommonResult<Boolean> modifyStatus(@RequestBody @Validated AdminMemberStatusCommand memberStatusCommand) {
        return CommonResult.success(memberCmdService.modifyStatus(memberStatusCommand));
    }
}
